The document is supposed to outline our best practices on the
javascript side, so make sure the code snippets actually conform
to the enforced style.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/919
bar = do_thing(b);
if (var == 5) {
- for (let i = 0; i < 10; i++) {
+ for (let i = 0; i < 10; i++)
print(i);
- }
} else {
print(20);
}
Always use either `const` or `let` when defining a variable.
```javascript
// Iterating over an array
- for (let i = 0; i < arr.length; ++i) {
+ for (let i = 0; i < arr.length; ++i)
let item = arr[i];
- }
// Iterating over an object's properties
for (let prop in someobj) {
All closures should be wrapped with Function.prototype.bind or use arrow
notation.
```javascript
- let closure1 = () => { this._fnorbate(); };
+ let closure1 = () => this._fnorbate();
let closure2 = this._fnorbate.bind(this);
```